﻿@using BookShop.Site.Models
@using PagedList
@using PagedList.Mvc
@model SalePageModel
@{
    ViewBag.Title = "Sách giảm giá | Book Shop Ngân Hà";
}

<ul class="breadcrumb">
    <li><a href="@Url.Action("Index", "Home")">Trang chủ</a></li>
    <li class="active">Sách giảm giá</li>
</ul>
<div class="row margin-bottom-40">
    @if (Model != null)
    {
        Html.RenderPartial("_CategorySidebar", new HomeViewModel { HasPriceSlider = false, CategoryList = Model.Categories });
        <div class="col-md-9 col-sm-7 my-product-list">
            <div class="row list-view-sorting clearfix">
                <div class="col-md-2 col-sm-2 list-view">
                    <a href="#"><i class="fa fa-th-large"></i></a>
                    <a href="#"><i class="fa fa-th-list"></i></a>
                </div>
                <div class="col-md-10 col-sm-10">
                    <div class="pull-right">
                        <label class="control-label">Show:</label>
                        <select id="page_size_dropdown" class="form-control input-sm">
                            <option value="12">12</option>
                            <option value="24">24</option>
                            <option value="48">48</option>
                        </select>
                    </div>
                </div>
            </div>
            <div class="row product-list">
                @foreach (var book in Model.Books)
                {
                    <div class="col-md-4 col-sm-6 col-xs-12">
                        @{ Html.RenderPartial("_Product", book); }
                    </div>
                }
            </div>
            <!-- BEGIN PAGINATOR -->
            <div class="row">
                <div class="col-md-4 col-sm-4 items-info">Tổng số: @ViewBag.TotalCount</div>
                @Html.PagedListPager((IPagedList)ViewBag.PageList, page => Url.Action("SalePage", "Home",
                    new
                    {
                        page,
                        pageSize = ViewBag.SearchPageSize,
                    }), new PagedListRenderOptions
                    {
                        DisplayLinkToFirstPage = PagedListDisplayMode.Always,
                        DisplayLinkToLastPage = PagedListDisplayMode.Always,
                        DisplayLinkToPreviousPage = PagedListDisplayMode.IfNeeded,
                        DisplayLinkToNextPage = PagedListDisplayMode.IfNeeded,
                        DisplayLinkToIndividualPages = true,
                        DisplayPageCountAndCurrentLocation = false,
                        MaximumPageNumbersToDisplay = 5,
                        DisplayEllipsesWhenNotShowingAllPageNumbers = true,
                        EllipsesFormat = "&#8230;",
                        LinkToFirstPageFormat = "««",
                        LinkToPreviousPageFormat = "«",
                        LinkToIndividualPageFormat = "{0}",
                        LinkToNextPageFormat = "»",
                        LinkToLastPageFormat = "»»",
                        PageCountAndCurrentLocationFormat = "Page {0} of {1}.",
                        ItemSliceAndTotalFormat = "Showing items {0} through {1} of {2}.",
                        FunctionToDisplayEachPageNumber = null,
                        ClassToApplyToFirstListItemInPager = null,
                        ClassToApplyToLastListItemInPager = null,
                        ContainerDivClasses = new[] { "col-md-8", "col-sm-8" },
                        UlElementClasses = new[] { "pagination", "pull-right" },
                        LiElementClasses = Enumerable.Empty<string>()
                    })
            </div>
            <!-- END PAGINATOR -->
        </div>
    }
</div>

@section Javascript{
    <script src="~/Content/assets/global/plugins/fancybox/source/jquery.fancybox.pack.js" type="text/javascript"></script>
    <script src='~/Content/assets/global/plugins/zoom/jquery.zoom.min.js' type="text/javascript"></script>
    <script src="~/Content/assets/global/plugins/uniform/jquery.uniform.min.js" type="text/javascript"></script>
    <script type="text/javascript">
        $(document).ready(function () {
            $('#page_size_dropdown').val('@ViewBag.SearchPageSize');
            $('#page_size_dropdown').on('change', function () {
                if (this.value) window.location.href = '/Home/SalePage?pageSize=' + this.value;
            });
        });
    </script>
}

@section Css{
    <link href="~/Content/assets/global/plugins/uniform/css/uniform.default.css" rel="stylesheet" type="text/css">
    <link href="~/Content/assets/global/plugins/fancybox/source/jquery.fancybox.css" rel="stylesheet">
}